refactor(queue): extract AI-slop-advisory gating/orchestration into its own module - #4946
Conversation
…ts own module Part of #4013's module-split sequence (step 4, after transient-locks.ts and signal-snapshot.ts): shouldCollectSlopEvidence, shouldRunSlopAiAdvisory, and runAiSlopForAdvisory move to src/queue/slop-detection.ts. Pure mechanical move, no behavior change -- a re-export shim keeps this file's own internal callers and existing test imports working unchanged. buildAiReviewDiff and buildSecretScanDiff move to src/review/review-diff.ts (their natural existing home -- both already wrapped buildUnifiedReviewDiff there) rather than staying in processors.ts, which would have made the new slop-detection.ts circularly import this file. Closed a genuine, previously-invisible coverage gap surfaced by isolating this code in its own small file: the BYOK declared-provider-matches-stored-key branch had no test exercising it either way, so two tests were added covering both the match and mismatch outcomes.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4946 +/- ##
=======================================
Coverage 94.24% 94.24%
=======================================
Files 444 445 +1
Lines 38854 38851 -3
Branches 14157 14154 -3
=======================================
- Hits 36617 36615 -2
Misses 1577 1577
+ Partials 660 659 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-11 02:26:42 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 1 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
src/queue/processors.ts. Step 4, aftertransient-locks.ts(refactor(queue): extract transient-lock primitives into their own module #4157) andsignal-snapshot.ts(refactor(queue): extract signal-snapshot generation into its own module #4820).shouldCollectSlopEvidence,shouldRunSlopAiAdvisory,runAiSlopForAdvisoryintosrc/queue/slop-detection.ts. Pure mechanical move — no behavior change.mergeReadinessGateEnabled(a trivial one-line predicate, still used byprocessors.ts's ownshouldCollectLinkedIssueEvidence) is inlined directly rather than imported back, for the same one-directional-dependency reason as duplicate-detection.ts'sgithubAdmissionKeyForTokeninline.buildAiReviewDiffandbuildSecretScanDiffmove tosrc/review/review-diff.ts— their natural existing home (both already wrappedbuildUnifiedReviewDiffthere) — rather than staying inprocessors.ts, which would have made the newslop-detection.tscircularly import this file just for one shared diff-builder. Both are used by 3+ other still-in-processors.tscallers, soprocessors.tsnow imports them back fromreview-diff.tsalongside its pre-existingbuildUnifiedReviewDiff/totalAddedLineCountimport.test/unit/advisory-ai-routing-call-sites.test.ts,test/unit/ai-slop.test.ts,test/unit/gate-check-policy.test.ts,test/unit/linked-issue-satisfaction-run.test.ts,test/unit/ai-review-advisory.test.ts,test/unit/patchless-secret-scan.test.tsimports from../../src/queue/processorsworking unchanged.runAiSlopForAdvisoryin its own small file surfaced a genuinely untested branch — whethersettings.aiReviewProvider, when explicitly set, matches or mismatches the stored BYOK key's provider (previously invisible insideprocessors.ts's overall coverage). Added two tests covering both outcomes (match → BYOK used; mismatch → falls back to Workers AI) rather than suppressing it.Part of #4013 (more extraction steps remain in the sequence — not closing the tracking issue).
Test plan
npx tsc --noEmit -p .— zero errorsnpx vitest run test/unit test/integration— 696/697 files passed (1 skipped, pre-existing)npm run test:coverage(unsharded) — 94.43% statements / 93.42% branches / 93.6% functions / 95.03% lines, no threshold failures;slop-detection.tsis 100% line + branch + function covered;review-diff.ts's only remaining gaps are in pre-existing, untouched code (keepHighSignalHunks/buildUnifiedReviewDiff), not in the newly-added functionsnpm run docs:drift-check,npm run manifest:drift-check,npm run engine-parity:drift-check— all oknpm audit --audit-level=moderate— 0 vulnerabilities